import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '提交时间',
    align:"center",
    sorter: true,
    dataIndex: 'createTime'
   },
   {
    title: '工单类型',
    align:"center",
    dataIndex: 'workOrderType_dictText'
   },
   {
    title: '客户名称',
    align:"center",
    dataIndex: 'customerName'
   },
   {
    title: '联系人',
    align:"center",
    dataIndex: 'contacts'
   },
   {
    title: '联系电话',
    align:"center",
    dataIndex: 'telephone'
   },
   {
    title: '上门地址',
    align:"center",
    dataIndex: 'homeAddress',
   },
   {
    title: '详细地址',
    align:"center",
    dataIndex: 'address'
   },
   {
    title: '车牌号',
    align:"center",
    dataIndex: 'licensePlate'
   },
   {
    title: '工单描述',
    align:"center",
    dataIndex: 'description'
   },
   {
    title: '预约时间',
    align:"center",
    dataIndex: 'appointmentTime'
   },
   {
    title: '服务时间',
    align:"center",
    sorter: true,
    dataIndex: 'serviceTime'
   },
   {
    title: '工单状态',
    align:"center",
    dataIndex: 'workOrderStatus_dictText'
   },
   {
    title: '结算状态',
    align:"center",
    dataIndex: 'settlementStatus_dictText'
   },
   {
    title: '完成时间',
    align:"center",
    sorter: true,
    dataIndex: 'finishTime'
   },
   {
    title: '优先级',
    align:"center",
    sorter: true,
    dataIndex: 'priority_dictText'
   },
   {
    title: '服务人员',
    align:"center",
    dataIndex: 'serviceStaff_dictText'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "联系人",
      field: 'contacts',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "联系电话",
      field: 'telephone',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "车牌号",
      field: 'licensePlate',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "工单状态",
      field: 'workOrderStatus',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"workOrderStatus"
      },
      //colProps: {span: 6},
 	},
	{
      label: "结算状态",
      field: 'settlementStatus',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"settlementstatus"
      },
      //colProps: {span: 6},
 	},
	{
      label: "是否免费",
      field: 'free',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"free"
      },
      //colProps: {span: 6},
 	},
	{
      label: "服务类型",
      field: 'serviceType',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"serviceType"
      },
      //colProps: {span: 6},
 	},
	{
      label: "优先级",
      field: 'priority',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"workOrderPriority"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表列表数据
export const followUpColumns: BasicColumn[] = [
   {
    title: '员工',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '回访时间',
    align:"center",
    dataIndex: 'createTime'
   },
   {
    title: '问题处理',
    align:"center",
    dataIndex: 'problemHandling_dictText'
   },
   {
    title: '收费情况',
    align:"center",
    dataIndex: 'feeSituation_dictText'
   },
   {
    title: '满意程度',
    align:"center",
    dataIndex: 'satisfactionLevel_dictText'
   },
   {
    title: '回访概述',
    align:"center",
    dataIndex: 'overview'
   },
   {
    title: '客户建议',
    align:"center",
    dataIndex: 'suggested'
   },
];
export const followUpFormSchema: FormSchema[] = [
  {
    label: '问题处理',
    field: 'problemHandling',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"problemHandling",
        type: "radio"
     },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请选择问题处理!'},
      ];
    },
  },
  {
    label: '收费情况',
    field: 'feeSituation',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"feeSituation",
        type: "radio"
     },
  },
  {
    label: '满意程度',
    field: 'satisfactionLevel',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"satisfactionLevel",
        type: "radio"
     },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请选择满意程度!'},
      ];
    },
  },
  {
    label: '回访概述',
    field: 'overview',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入回访概述!'},
      ];
    },
  },
  {
    label: '客户建议',
    field: 'suggested',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入客户建议!'},
      ];
    },
  },
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表表格配置

// 高级查询数据
export const superQuerySchema = {
  createTime: {title: '提交时间',order: 0,view: 'datetime', type: 'string',},
  workOrderType: {title: '工单类型',order: 1,view: 'list', type: 'string',dictCode: 'workOrderType',},
  customerName: {title: '客户名称',order: 2,view: 'text', type: 'string',},
  contacts: {title: '联系人',order: 3,view: 'text', type: 'string',},
  telephone: {title: '联系电话',order: 4,view: 'text', type: 'string',},
  homeAddress: {title: '上门地址',order: 5,view: 'pca', type: 'string',},
  address: {title: '详细地址',order: 6,view: 'text', type: 'string',},
  licensePlate: {title: '车牌号',order: 7,view: 'text', type: 'string',},
  description: {title: '工单描述',order: 8,view: 'textarea', type: 'string',},
  appointmentTime: {title: '预约时间',order: 9,view: 'datetime', type: 'string',},
  serviceTime: {title: '服务时间',order: 10,view: 'datetime', type: 'string',},
  workOrderStatus: {title: '工单状态',order: 11,view: 'number', type: 'number',dictCode: 'workOrderStatus',},
  settlementStatus: {title: '结算状态',order: 12,view: 'number', type: 'number',dictCode: 'settlementstatus',},
  finishTime: {title: '完成时间',order: 15,view: 'datetime', type: 'string',},
  priority: {title: '优先级',order: 16,view: 'number', type: 'number',dictCode: 'workOrderPriority',},
  serviceStaff: {title: '服务人员',order: 17,view: 'sel_user', type: 'string',},
  //子表高级查询
  followUp: {
    title: '工单回访',
    view: 'table',
    fields: {
        createBy: {title: '员工',order: 0,view: 'text', type: 'string',},
        createTime: {title: '回访时间',order: 1,view: 'datetime', type: 'string',},
        problemHandling: {title: '问题处理',order: 2,view: 'number', type: 'number',dictCode: 'problemHandling',},
        feeSituation: {title: '收费情况',order: 3,view: 'number', type: 'number',dictCode: 'feeSituation',},
        satisfactionLevel: {title: '满意程度',order: 4,view: 'number', type: 'number',dictCode: 'satisfactionLevel',},
        overview: {title: '回访概述',order: 5,view: 'textarea', type: 'string',},
        suggested: {title: '客户建议',order: 6,view: 'textarea', type: 'string',},
    }
  },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
